package control
{
	import com.google.maps.LatLng;
	
	import flash.display.Shape;
	import flash.geom.Point;

	public class SimpleCircle extends SimpleShape
	{
		public function SimpleCircle(latlngs:Array,option:DrawOptions)
		{
			
			super();
			this.cloud = new Shape();
			this.latlngs = latlngs;
			this.addChild(cloud);
			if(option != null)
				this.option = option;
		}
		
		protected override function draw():void
		{
			try
			{
				this.cloud.graphics.clear();
				
				cloud.graphics.lineStyle(option.lineWidth,option.drawColor,option.ancho);
				
	
				var point1:Point = this.pane.fromLatLngToPaneCoords(this.latlngs[0]);
				var point2:Point = this.pane.fromLatLngToPaneCoords(this.latlngs[1]);
				
				
				// get the radius which is the two point distanse / 2 
				var radius:Number = Math.sqrt((point2.y * point2.y - point1.y * point1.y ) + (point2.x * point2.x - point1.x * point1.x))/2;
				
				var centx:Number = point1.x + (point2.x - point1.x)/2;
				var centy:Number = point2.y + (point2.y - point1.y)/2;
				
				cloud.graphics.beginFill(option.fillColor,option.ancho);
				cloud.graphics.drawCircle(centx,centy,radius);
				cloud.graphics.endFill();
			}catch(e:Error)
			{
				trace("SimpleCircle.as line 43 error " + e.toString())
			}
		}
	}
}